From c526d560a3e8ed9b2dc9a23825b8979c00a152ba Mon Sep 17 00:00:00 2001 From: Factiven Date: Mon, 1 May 2023 01:09:33 +0700 Subject: Update v3.5 > Bug Fixes > Editor List Update v0.8 > Display adjustment on search page --- pages/search/[param].js | 82 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 29 deletions(-) (limited to 'pages/search/[param].js') diff --git a/pages/search/[param].js b/pages/search/[param].js index 31760c4..f38ba76 100644 --- a/pages/search/[param].js +++ b/pages/search/[param].js @@ -9,6 +9,7 @@ import Head from "next/head"; import Footer from "../../components/footer"; import { useAniList } from "../../lib/useAnilist"; +import Image from "next/image"; const genre = [ "Action", @@ -53,6 +54,8 @@ export default function Card() { let hasil = null; let tipe = "ANIME"; + let s = undefined; + let y = NaN; const query = router.query; if (query.param !== "anime" && query.param !== "manga") { @@ -60,19 +63,42 @@ export default function Card() { } else if (query.param === "anime") { hasil = null; tipe = "ANIME"; + if ( + query.season !== "WINTER" && + query.season !== "SPRING" && + query.season !== "SUMMER" && + query.season !== "FALL" + ) { + s = undefined; + y = NaN; + } else { + s = query.season; + y = parseInt(query.seasonYear); + } } else if (query.param === "manga") { hasil = null; tipe = "MANGA"; + if ( + query.season !== "WINTER" && + query.season !== "SPRING" && + query.season !== "SUMMER" && + query.season !== "FALL" + ) { + s = undefined; + y = NaN; + } else { + s = query.season; + y = parseInt(query.seasonYear); + } } - // ; + + // console.log(tags); const [search, setQuery] = useState(hasil); const [type, setSelectedType] = useState(tipe); - const [seasonYear, setSeasonYear] = useState(); - const [season, setSeason] = useState(); const [genres, setSelectedGenre] = useState(); - const [perPage, setPerPage] = useState(10); - const [sort, setSelectedSort] = useState(["POPULARITY_DESC"]); + const [sort, setSelectedSort] = useState(); + // console.log(data); const [isVisible, setIsVisible] = useState(false); @@ -83,16 +109,15 @@ export default function Card() { async function advance() { setLoading(true); - const data = await aniAdvanceSearch( - search, - type, - seasonYear, - season, - genres, - page, - perPage, - sort - ); + const data = await aniAdvanceSearch({ + search: search, + type: type, + genres: genres, + page: page, + sort: sort, + season: s, + seasonYear: y, + }); if (data.media.length === 0) { setNextPage(false); } else if (data !== null && page > 1) { @@ -112,7 +137,7 @@ export default function Card() { setPage(1); setNextPage(true); advance(); - }, [search, type, seasonYear, season, genres, perPage, sort]); + }, [search, type, genres, sort, s, y]); useEffect(() => { advance(); @@ -183,7 +208,7 @@ export default function Card() { TITLE
{loading ? "" @@ -362,7 +387,7 @@ export default function Card() { -
-

+

{anime.status === "RELEASING" ? ( ) : anime.status === "NOT_YET_RELEASED" ? ( @@ -407,10 +431,10 @@ export default function Card() { {[1, 2, 4, 5, 6, 7, 8].map((item) => (
- +
))} -- cgit v1.2.3